home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / System / BoingBag1 / Contributions / InstallerNG / GUI-API / example / igui_AskString.c < prev    next >
C/C++ Source or Header  |  1999-11-01  |  3KB  |  103 lines

  1.  
  2. #include "includes.h"
  3. #include "installergui_data.h"
  4.  
  5. #include <string.h>
  6.  
  7. /********************************************************************
  8.  *
  9.  *  DESCRIPTION
  10.  *
  11.  *  ask the user for a string. i.e. simply create a string gadget,
  12.  *  set its content to the default string (if any) and return
  13.  *  the content (a copy of the content, since disposing the gadget
  14.  *  will dispose the content too!)
  15.  *
  16.  *  IN:  application - pointer to the private application structure
  17.  *       localenv - the local environment of the related ASKSTRING function
  18.  *
  19.  *  OUT: the string, typed in by the user
  20.  *
  21.  */
  22.  
  23. /********************************************************************
  24.  *
  25.  *  STATIC
  26.  *
  27.  */
  28.  
  29. /********************************************************************
  30.  *
  31.  *  EXTERN
  32.  *
  33.  */
  34.  
  35. /********************************************************************
  36.  *
  37.  *  PUBLIC
  38.  *
  39.  */
  40.  
  41. /********************************************************************
  42.  *
  43.  *  CODE
  44.  *
  45.  */
  46.  
  47. char * __asm igui_AskString(register __a0 APTR application,
  48.                             register __a1 struct FunctionEnvironment *localenv)
  49. {
  50.   #ifdef DEBUG
  51.   DEBUG_MAKRO
  52.   #endif
  53.  
  54.   {
  55.     struct Application *app = (struct Application *) application;
  56.  
  57.     APTR str, txt = NULL;
  58.     APTR strobj,
  59.          obj = GroupObject,
  60.                  Child, HVSpace,
  61.                  Child, TextObject,
  62.                    MUIA_Frame, MUIV_Frame_None, //MUIV_Frame_Text,
  63.                    MUIA_Text_Contents, localenv->fe_Prompt,
  64.                    MUIA_Text_SetMin, TRUE,
  65.                    MUIA_Text_PreParse, "\33c",
  66.                  End,
  67.                  Child, strobj = StringObject,
  68.                    MUIA_Frame, MUIV_Frame_String,
  69.                    MUIA_String_Contents, localenv->fe_Default,
  70.                    MUIA_String_Format, MUIV_String_Format_Center,
  71.                  End,
  72.                  Child, HVSpace,
  73.                End;
  74.  
  75.     // maybee BACK (if specified) or respect the swing mode
  76.     if (localenv->fe_Back)         { guistuff_SetBackButton(app, TRUE); }
  77.     else if (!app->app_SWING_Mode) { igui_NameCancel(app, (char *) app->app_GlobalEnv[GENV_ABORT_BUTTON]); }
  78.  
  79.     //
  80.     if (guistuff_NewContent(app, obj))
  81.     {
  82.       //
  83.       igui_WaitApp(app);
  84.       if (!igui_QuitApp(app))
  85.       {
  86.         //
  87.         GetAttr(MUIA_String_Contents, strobj, (ULONG *) &str);
  88.  
  89.         txt = sav_AllocVec(strlen(str) + 1, MEMF_ANY);
  90.         if (txt) { strcpy(txt, str); }
  91.         else     { /* NO MEMORY */ }
  92.       }
  93.  
  94.       igui_EmptyPanel(app);
  95.     }
  96.     else { /* NO GUI OBJECT */ }
  97.  
  98.     if (localenv->fe_Back) { guistuff_SetBackButton(app, FALSE); }
  99.     return(txt);
  100.   }
  101. }
  102.  
  103.